﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using blackhouse.BlackApart.Business;
using blackhouse.BlackApart.Business.Apartments;

namespace blackhouse.BlackApart.Web.Modules {
    public partial class ApartmentGroupArrayProperties : System.Web.UI.UserControl {

        #region Fields

        private Dictionary<string, string> data;

        #endregion

        #region Properties

        public string PropertyKey { get; set; }

        #endregion

        #region Event Handlers

        protected override void OnInit(EventArgs e) {
            base.OnInit(e);

            this.SetInstance();
        }

        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);

            this.PopulateControls();
        }

        #endregion

        #region Methods

        private void SetInstance() {

            IApartmentGroup group = DisplayApartmentTypeState.GetCurrentState().ApartmentType;
            if (group != null)
                data = group.GetArrayProperty(this.PropertyKey);
            else
                data = new Dictionary<string, string>();
        }

        private void PopulateControls() {
            this.rptProperties.DataSource = this.data;
            this.rptProperties.DataBind();
        }

        #endregion

    }
}